 <?php
 
    class Mp3_InfoArtista{
		public $arid;
		public $tipus;
		public $nom;
		public $categoria;
		public $alias = array();
		public $sortname;
		public $inici;
		public $final;
		public $comentari;
		public $pais;
		public $genere;
		public $etiqueta;
		
				
		public function __construct($xml){
			 // $xml = new SimpleXMLElement('<artist score="100" type="Person" id="d7102b7e-5a12-41b0-9050-d5762d22e2cb">
				  // <name>Fred</name> 
				  // <sort-name>Fred</sort-name> 
				  // <disambiguation>Swedish techno producer Cari Lekebusch</disambiguation> 
				  // <alias-list>
					  // <alias>Fred 4</alias> 
					  // <alias>Fred 3</alias> 
					  // <alias>Fred 2</alias> 
					  // <alias>Fred</alias> 
				  // </alias-list>
				  // <life-span>
					// <begin>2011-10-02</begin>
				  // </life-span>
			 // </artist>');
			 $this->arid=$xml['id'];
			 $this->tipus=$xml['type'];
			 foreach ( $xml->children() AS $tag => $child ){
				switch ($tag) {
					case 'name':
						$this->nom = $child;
						break;
					case 'sort-name':
						$this->sortname = $child;
						break;
					case 'deambugation':
						$this->categoria = $child;
						break;
					case 'alias-list':
						foreach($child->children() as $tag2=>$child2) {
							$this->alias [] = $child2;
						}
						break;
					case 'life-span':
						foreach($child->children() as $tag2=>$child2) {
							if ($tag == 'begin'){
								$this->inici = $child2;
							}else{
								$this->final = $child2;
							}
						}
						break;
						
					case 'comment':
						$this->comentari = $child;
						break;
						
					case 'country':
						$this->pais = $child;
						break;
						
					case 'gender':
						$this->genere = $child;
						break;
						
					case 'tag':
						$this->etiqueta = $child;
						break;
				}
			 }
		
		}
		
	}
  